# Pandas
df_ell = df.query('name == ["Elliot"]')
ell = (
ggplot(data=df_ell)
+ geom_line(mapping = aes(x = 'year', y = 'Total', color='name'))
+ scale_color_manual(values={'Elliot': 'blue'})
+ scale_x_continuous(limits=[1950,2025], format = 'd', expand=[0,0])
+ scale_y_continuous(format='d')
+ labs(
title="Elliot... What?"
)
+ theme(panel_grid=element_line(linetype=1, color = "white"),
panel_background=element_rect(fill="#e5ecf6", linetype=0),
axis_line_x=element_blank(),
axis_ticks_x=element_blank()
)
+ geom_text(x = 1982, y = 1300, label="E.T. Released", hjust="right", size=6)
+ geom_text(x = 1985, y = 1300, label="Second Released", hjust="left", size=6)
+ geom_text(x = 2002, y = 1300, label="Third Released", hjust="left", size=6)
+ geom_vline(xintercept=1982, color="red", linetype="dashed")
+ geom_vline(xintercept=1985, color="red", linetype="dashed")
+ geom_vline(xintercept=2002, color="red", linetype="dashed")
)
display(ell)
ggsave(ell, filename="elliot_pandas.svg", path="./plots/")
# Polars
print(f"\nUsing Polars")
df_ell_pl = df_pl.filter(pl.col('name').is_in(["Elliot"]))
ell_pl = (
ggplot(data=df_ell_pl)
+ geom_line(mapping = aes(x = 'year', y = 'Total', color='name'))
+ scale_color_manual(values={'Elliot': 'blue'})
+ scale_x_continuous(limits=[1950,2025], format = 'd', expand=[0, 0])
+ scale_y_continuous(format='d')
+ labs(
title="Elliot... What?"
)
+ theme(panel_grid=element_line(linetype=1, color = "white"),
panel_background=element_rect(fill="#e5ecf6", linetype=0),
axis_line_x=element_blank(),
axis_ticks_x=element_blank()
)
+ geom_text(x = 1982, y = 1300, label="E.T. Released", hjust="right", size=6)
+ geom_text(x = 1985, y = 1300, label="Second Released", hjust="left", size=6)
+ geom_text(x = 2002, y = 1300, label="Third Released", hjust="left", size=6)
+ geom_vline(xintercept=1982, color="red", linetype="dashed")
+ geom_vline(xintercept=1985, color="red", linetype="dashed")
+ geom_vline(xintercept=2002, color="red", linetype="dashed")
)
display(ell_pl)
# the sv is simply to suppress the output
sv = ggsave(ell_pl, filename="elliot_polars.svg", path="./plots/")